< previous page page_304 next page >

Page 304
Creating a Property Page is a lot like creating a form, except that a Property Page doesn't execute a Load event when it's displayed.
Your Property Pages dialog box must do only three things:
8694cbadb9b1ef7075903f6f95fc1db2.gif
In the SelectionChanged event, obtain the property values to be edited.
8694cbadb9b1ef7075903f6f95fc1db2.gif
Set the PropertyPage object's Changed property whenever users edit a property value.
8694cbadb9b1ef7075903f6f95fc1db2.gif
In the ApplyChanges event, copy the edited property values back to the selected control (or controls).
The SelectionChanged event occurs when the property page is displayed and when the list of currently selected controls changes.
Tip
Always treat the
SelectionChanged event as though your Property Page is being loaded for the first time. As you'll see, changing the selection actually changes the state of the Property Page.

The most important thing you need to do in the SelectionChanged event is to set the values of the controls that display the property values to be edited. An example of this is as follows:
Private Sub PropertyPage_SelectionChanged()
    txtTableName.Text = SelectedControls(0).TableName
    txtDisplayField.Text = SelectedControls(0).DisplayField
End Sub
The code in the SelectionChanged event is taking the value for each property for the first control in the collection and assigning it to the appropriate control on the property page. In a single selected control, this places all the control's property values in fields where users can edit them. If a control requires a selection, you could use a combo box to display the list for users of the control to choose from. The list in the combo box would be populated in the SelectionChanged event routine.
To tell Visual Basic that one or more properties on a property page have changed, the PropertyPage object's Changed property must be set to True. Because there's really no way of knowing which property might have been changed, you would add this code for every property displayed on the page. For example, to notify the PropertyPage of changes in the ctlDatabase property, you would use the following code:
Private Sub ctlDatabase_Changed()
    Changed = True
End Sub

 
< previous page page_304 next page >

If you like this book, buy it!